package com.xizi.leetcode周赛;

public class _5786可移除字符的最大数目 {
    public static void main(String[] args) {
        char[] arr = new char[]{'a', 'b'};
        System.out.println(arr.toString());

    }

    public int maximumRemovals(String s, String p, int[] removable) {
        char[] arr = s.toCharArray();
        int res = 0;
        for (int i = 0; i < removable.length; i++) {
            arr[removable[i]] = '0';
            String s1 = new String(arr);
            if (!check(p, s1)) {
                return res;
            } else {
                res++;
                s = s1;
            }
        }
        return res;
    }

    //检查子序列
    public boolean check(String s, String t) {
        int index = -1;
        for (char c : s.toCharArray()) {
            index = t.indexOf(c, index + 1);
            if (index == -1) return false;
        }
        return true;
    }
}
